{ ***  cef_task_capi.h  *** }

  PCefTask = ^TCefTask;
  PCefTaskRunner = ^TCefTaskRunner;

  // Implement this structure for asynchronous task execution. If the task is
  // posted successfully and if the associated message loop is still running then
  // the execute() function will be called on the target thread. If the task fails
  // to post then the task object may be destroyed on the source thread instead of
  // the target thread. For this reason be cautious when performing work in the
  // task object destructor.
  TCefTask = record
    // Base structure.
    base: TCefBase;

    // Method that will be executed on the target thread.
    execute: procedure(self: PCefTask); cconv;
  end;


  // Structure that asynchronously executes tasks on the associated thread. It is
  // safe to call the functions of this structure on any thread.
  //
  // CEF maintains multiple internal threads that are used for handling different
  // types of tasks in different processes. The cef_thread_id_t definitions in
  // cef_types.h list the common CEF threads. Task runners are also available for
  // other CEF threads as appropriate (for example, V8 WebWorker threads).
  TCefTaskRunner = record
    // Base structure.
    base: TCefBase;

    // Returns true (1) if this object is pointing to the same task runner as
    // |that| object.
    is_same: function(self, that: PCefTaskRunner): Integer; cconv;

    // Returns true (1) if this task runner belongs to the current thread.
    belongs_to_current_thread: function(self: PCefTaskRunner): Integer; cconv;

    // Returns true (1) if this task runner is for the specified CEF thread.
    belongs_to_thread: function(self: PCefTaskRunner; threadId: TCefThreadId): Integer; cconv;

    // Post a task for execution on the thread associated with this task runner.
    // Execution will occur asynchronously.
    post_task: function(self: PCefTaskRunner; task: PCefTask): Integer; cconv;

    // Post a task for delayed execution on the thread associated with this task
    // runner. Execution will occur asynchronously. Delayed tasks are not
    // supported on V8 WebWorker threads and will be executed without the
    // specified delay.
    post_delayed_task: function(self: PCefTaskRunner; task: PCefTask; delay_ms: Int64): Integer; cconv;
  end;

    // Returns the task runner for the current thread. Only CEF threads will have
    // task runners. An NULL reference will be returned if this function is called
    // on an invalid thread.
    tfn_cef_task_runner_get_for_current_thread = function: PCefTaskRunner; cdecl;

    // Returns the task runner for the specified CEF thread.
    tfn_cef_task_runner_get_for_thread = function(
        threadId: TCefThreadId): PCefTaskRunner; cdecl;

    // Returns true (1) if called on the specified thread. Equivalent to using
    // cef_task_runner_t::GetForThread(threadId)->belongs_to_current_thread().
    tfn_cef_currently_on = function(
        threadId: TCefThreadId): Integer; cdecl;

    // Post a task for execution on the specified thread. Equivalent to using
    // cef_task_runner_t::GetForThread(threadId)->PostTask(task).
    tfn_cef_post_task = function(
        threadId: TCefThreadId;
        task: PCefTask): Integer; cdecl;

    // Post a task for delayed execution on the specified thread. Equivalent to
    // using cef_task_runner_t::GetForThread(threadId)->PostDelayedTask(task,
    // delay_ms).
    tfn_cef_post_delayed_task = function(
        threadId: TCefThreadId;
        task: PCefTask;
        delay_ms: Int64): Integer; cdecl;

